package com.user.command;

import java.util.Iterator;
import java.util.List;

import org.apache.ibatis.session.SqlSession;

import com.user.applaction.SessionManager;
import com.user.mapping.UserMapping;
import com.user.pojo.User;
import com.user.tool.Tool;

public class SelectCommand implements Command {

	@Override
	public void excute() {
		SqlSession session = SessionManager.getInstance().getSession();
		UserMapping mapper = session.getMapper(UserMapping.class);
		long begin = System.currentTimeMillis();
		Tool.printMsg("正在载入所有用户信息... ");
		List<User> userList = mapper.getAllUsers();
		

		Iterator<User> it = userList.iterator();
		while (it.hasNext()) {
			System.out.println(it.next());
		}
		long end = System.currentTimeMillis();
		long res = end - begin;
		Tool.printMsg("载入完成," + res + "毫秒");
		session.close();
	}

}
